﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Hisun.Models;
using Hisun.Controllers;

namespace Hisun.View.ReportQuery
{
    public partial class Report_FZCZCCBB : AbcPageBase
    {
        HisunDBDataContext db = new HisunDBDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                AbcFullAccountPeriod MyFullAp = new AbcFullAccountPeriod();

                MyFullAp.FullAccountPeriodToDropdownlist(DropDownList_Year, DropDownList_Month, Application["accountPeriod"].ToString());


            }
        }

        protected void Button_Query_Click(object sender, EventArgs e)
        {
            string MyQueryAccountPeriod = DropDownList_Year.SelectedValue.ToString() + DropDownList_Month.SelectedValue.ToString(); ;
  


            string CurrentUser = Session[ServerVars.sysSessionUserName].ToString();

            var IsValidString = from a in db.TABC_JS_AccountPeriods
                                where a.会计期间ID == MyQueryAccountPeriod
                                select a;
            if (IsValidString.Count() == 0)
            {
                Response.Write("<Script>alert('会计期间不存在，请检查输入是否正确')</Script>");
                return;
            }
            else if (IsValidString.Count() == 1)
            {
                CostReport MyReport = new CostReport();
                string myHtmlReport = "";

                if (CheckBox_Other.Checked == true)
                {

                    myHtmlReport = MyReport.WriteExcel_Report_FZCZCCBB_Other(MyQueryAccountPeriod, CurrentUser,"no");
                    Response.Redirect("/Report/UserReport/" + myHtmlReport + ".html");
                
                }
                else
                {

                    myHtmlReport = MyReport.WriteExcel_Report_FZCZCCBB(MyQueryAccountPeriod, CurrentUser,"no");
                    Response.Redirect("/Report/UserReport/" + myHtmlReport + ".html");
                }



            }
        }
    }
}
